< previous page page_137 next page >

Page 137
The program then uses the SelStart and SelLength properties of the upper two controls to select all their text. Similarly, it sets the lower-right control's SelStart and SelLength properties to select its text. The program sets the lower-right control's SelRTF property equal to the same property in the upper-left control. This copies the text from the upper-left control into the lower-right control with its formatting codes.
Next, the program sets the lower-right control's SelStart and SelLength properties to the end of the control's text. It sets the control's SelText property to vbCrLf to add a carriage return to the text.
Once again, the control sets the lower-right control's SelStart and SelLength properties to the end of the control's text. Finally, it sets the control's SelRTF property to the SelRTF value of the control in the upper right. That finishes combining the text of the two upper controls.
The following code shows how program Rich combines the text in its input controls.
e10a6a0a59f035e870d90cca05b85fce.gif
' Combine the values in the rchInput controls.
Private Sub cmdCombine_Click()
Dim sel_start(0 To 1) As Integer
Dim sel_length(0 To 1) As Integer
Dim i As Integer

    ' Combine text only.
    rchOutput(0).Text = rchInput(0).Text & _
        vbCrLf & rchInput(1).Text

    ' Save the current SelStart and SelLength values.
    For i = 0 To 1
        sel_start(i) = rchInput(i).SelStart
        sel_length(i) = rchInput(i).SelLength
        rchInput(i).SelStart = 0
        rchInput(i).SelLength = Len(rchInput(i).Text)
    Next i

    ' Combine the text only.
    rchOutput(0).Text = rchInput(0).Text & _
        vbCrLf & rchInput(1).Text

    ' Combine the rich text values.
    ' Copy the first control's text with RTF codes.
    rchOutput(1).SelStart = 0
    rchOutput(1).SelLength = Len(rchOutput(1).Text)
    rchOutput(1).SelRTF = rchInput(0).SelRTF

    ' Add vbCrLf to the end.
    rchOutput(1).SelStart = Len(rchOutput(1).Text)
    rchOutput(1).SelLength = 0
    rchOutput(1).SelText = vbCrLf

 
< previous page page_137 next page >